package com.team.mp.api.controller;


import com.team.mp.api.bo.HealthRecordAddBo;
import com.team.mp.api.service.intf.HealthrecordService;
import com.team.mp.mapper.entity.HealthRecord;
import com.team.mp.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.*;

/**
 * @program: MyProject
 * @description: 控制层实现常用的外部接口
 * @author: yyj
 * @create: 2023-03-28 20:40:12
 */
@RestController
@RequestMapping("/api/healthrecord/")
@Api(tags = "居民健康记录")
public class HealthrecordController {
    /**
     * 注入业务逻辑层对象
     */
    @Resource
    private HealthrecordService service;

    /**
     * 新增内容
     */
    @ApiOperation(value = "新增健康记录")
    @PostMapping("save")
    public R save(@RequestBody HealthRecordAddBo bo) {
        return service.save(bo);
    }

    /**
     * 修改内容
     */
    @ApiOperation(value = "健康记录修改")
    @PostMapping("update")
    public R update(@RequestBody HealthRecord healthrecord) {
        return service.update(healthrecord);
    }

    /**
     * 查询 所有数据
     */
    @ApiOperation(value = "实现全部查询")
    @GetMapping("all.do")
    public R all() {
        return service.queryAll();
    }

    /**
     * 根据类型和餐前餐后进行查询
     */
    @ApiOperation(value = "根据类型和餐前后查询居民健康记录")
    @GetMapping("getdetail")
    public R getDetail(Integer uid, Integer type, Integer mealornot, int page, int size) {
        return service.queryByCond(uid, type, mealornot, page, size);
    }

    /**
     * 删除 单个数据
     */
    @ApiOperation(value = "删除健康记录")
    @DeleteMapping("del")
    public R del(long id) {
        return service.del(id);
    }
}
